﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using System.Windows.Forms;
namespace version1
{
    public class NPC : Visible
    {

        private int _state=1;

        public int State
        {
            get { return _state; }
            set { _state = value; }
        }
        private void InitButton(ContentManager content, string[] str, ref int n, ref Vector2 _TopLeft)
        {
            TopLeft = _TopLeft; ;
            Size = _Size;
            sprite = new List<Sprite2D>();
            Texture2D[] text = new Texture2D[n/5];
            for (int j = 0; j < 5; j++)
            {
                for (int i = 0; i < 10; i++)
                {
                    text[i] = content.Load<Texture2D>("Tuong//" + str[i + j * 10]);
                    
                }

                
                Sprite2D temp = new Sprite2D(text, _TopLeft);

                sprite.Add(temp);
            }
            nsprite = sprite.Count;
        }
        public NPC(ContentManager content, string[] str,int n,Vector2 _TopLeft,Vector2 _size)
        {
            InitButton(content, str, ref n, ref _TopLeft);

        }     
        public NPC(ContentManager content, string str, int n, Vector2 _TopLeft, Vector2 _size)
        {
            string[] strtext = new string[n];
            for (int i = 0; i < n; i++)
            {
                strtext[i] = str + (i + 1).ToString("00");
            }
            InitButton(content, strtext, ref n, ref _TopLeft);
        }
        public void Update(GameTime gametime,int state)
        {
            State = state;
            if (State == 1)
                sprite[0].Update(gametime);
            if (State == 3)
                sprite[2].Update(gametime);
            if (State == 5)
                sprite[4].Update(gametime);
        }
        public void Draw(SpriteBatch batch,GameTime gametime)
        {

            if (State == 1)
                sprite[0].Draw(batch,gametime);
            if (State == 3)
                sprite[2].Draw(batch, gametime);
            if (State == 5)
                sprite[4].Draw(batch, gametime);
        }
    }
}
